﻿package
{
	import flash.display.MovieClip;
	import flash.events.MouseEvent;
	
	
	public class Converter extends MovieClip
	{
		
		public function Converter() 
		{
			init();
		}
		
		private function init ( ) :void
		{
			
			bt0.addEventListener(MouseEvent.CLICK, _click0);
			bt1.addEventListener(MouseEvent.CLICK, _click1);
			
		}
		
		private function _click0 ( evt :MouseEvent ) :void 
		{
			var s :String = ta0.text;
			var a :/*String*/Array = s.split(",");
			
			var n0 :int, n1 :int;
			var str :String = "";
			
			for ( var i :int = 0; i < a.length; i += 2 )
			{
				n0 = parseInt(a[i]) + ns0.value;
				n1 = parseInt(a[i + 1]) + ns1.value;
				
				str += n0 + "," + n1 + ",";
			}
			
			str = str.slice(0, str.length - 1);
			ta1.text = str;
			
		}
		
		private function _click1 ( evt :MouseEvent ) :void 
		{
			var s :String = ta2.text;
			var a :/*String*/Array = s.split(",");
			
			var n :Number;
			var str :String = "";
			
			
			for ( var i :int = 0; i < a.length; i ++ )
			{
				n = parseInt(a[i]) + ns2.value;
				
				str += n + ",";
			}
			
			str = str.slice(0, str.length - 1);
			ta3.text = str;
		}
		
		
	}
	
}